cmake_minimum_required(VERSION 3.12)
project(tflite_test)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)


find_package(OpenCV REQUIRED)


set(FLATBUFFERS_INCLUDE_DIR /usr/local/include)
set(FLATBUFFERS_LIBRARY_DIR /usr/local/lib)
set(TFLITE_INCLUDE_DIR /usr/local/include)


include_directories(
    ${FLATBUFFERS_INCLUDE_DIR}
    ${TFLITE_INCLUDE_DIR}
    ${CMAKE_SOURCE_DIR}/include
    ${OpenCV_INCLUDE_DIRS}
)


link_directories(
    ${FLATBUFFERS_LIBRARY_DIR}
    ${CMAKE_SOURCE_DIR}/lib
)


add_executable(tflite_test src/main.cpp)


target_link_libraries(tflite_test
    tensorflowlite
    flatbuffers
    ${OpenCV_LIBS}
    dl
    pthread
)


target_compile_definitions(tflite_test PRIVATE
    TFLITE_ENABLE_XNNPACK=1
)


if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
    target_compile_options(tflite_test PRIVATE
        -mfpu=neon
        -mfloat-abi=hard
    )
endif()